// ---------------------------------------------------------------------
//
// -- 曾今的王者列表item
// -- author £
//
// ---------------------------------------------------------------------

cc.Class({
    extends: cc.Component,

    properties: {
        lbScore: cc.Label,
        lbName: cc.Label,
        lbDate: cc.Label,
        head: cc.Sprite,
        defaultHead: cc.SpriteFrame,
    },

    ctor: function () {
        // this._headT = new cc.Texture2D();
    },

    // use this for initialization
    onLoad: function () {
        
    }, 

    start: function () {
    },

    setData: function (data) {
        if (!data) return; 

        let date = new Date();

        date.setTime(data.date_time * 1000);
        this.reset();

        this.lbName.string = data.nick_name;
        this.lbScore.string = data.history_best_score;
        this.lbDate.string = (date.getMonth() + 1) + '-' + date.getDate();
        require('Platform').setHead(data.avatar, data.user_id, this.head);
    },

    reset: function () {
        this.lbName.string = '';
        this.lbScore.string = '';
        this.lbDate.string = '';
        this.head.spriteFrame = this.defaultHead;
    },

    // called every frame, uncomment this function to activate update callback
    // update: function (dt) {

    // },
});
